<div id="page_content">
    <?php if (!is_null($this->poll)): ?>
    <h2><?= $this->t->_('Current poll') ?></h2>
    <h3><?= $this->poll->question ?></h3>
    <div id="pages_list">
        <div class="poll">
            <?php
            $sum = 0;
            foreach ($this->answers as $v)
                $sum += $v->votes;

            foreach ($this->answers as $v) {
                if ($sum <> 0) {
                    $width = round($v->votes / $sum * 100);
                } else {
                    $width = 0;
                }
                echo '<div class="answer">' . $v->answer . '</div>';
                echo '<div class="result">' . $width . '% (' . $v->votes . ')</div>';
                echo '<div class="bar"><div style="width: ' . $width . '%;" class="foreground"></div></div>';
            }
            echo '<div class="result">' . $this->t->_('Total votes')  . ': ' . $sum . '</div>';
            ?>
        </div>
    </div>
    <?php endif; ?>
    <h2><?= $this->t->_('Polls') ?></h2>
    <div id="pages_list">
        <ul>
            <?php foreach ($this->polls as $poll) {
            ?>
                <li><a href="<?= ADMIN_URL . '/pages/modify/id/' . $this->section->id . '/a/edit/pid/' . $poll->id ?>" class="active" ><?= $poll->question ?></a></li>
            <?php } ?>
        </ul>
    </div>

</div>
<div id="sidebar">
    <a href="<?= ADMIN_URL . '/pages/modify/id/' . $this->section->id . '/a/new' ?>" class="sidebar_button add_button"><?= $this->t->_("New poll") ?></a>
</div>

